/**
  frame-buffer.h - Created by Timothy Morey on 5/17/2012
*/

#ifndef __FRAME_BUFFER_H
#define __FRAME_BUFFER_H

#include "mutex.h"
#include "libnvn.h"

typedef struct
{
  char* Buffer;
  int Length;
} Frame;

typedef struct
{
  Frame* Frames;
  int NFrames;
  int FirstFrame;
  int LastFrame;
  Mutex Mutex;
} FrameBuffer;

/**
  @return An nvn error code indicating the success of the operation.
*/
EXPORT int AddFrameToBuffer(FrameBuffer* buf, const char* frame, int frameSize, int* frameindex);

/**
  @return An nvn error code indicating the success of the operation.
*/
EXPORT int DestroyFrameBuffer(FrameBuffer* buf);

/**
  @return An nvn error code indicating the success of the operation.
*/
EXPORT int ExpandFrameBuffer(FrameBuffer* buf, int n);

/**
  @return An nvn error code indicating the success of the operation.
*/
EXPORT int GetFrameCount(FrameBuffer* buf, int* count);

/**
  @return An nvn error code indicating the success of the operation.
*/
EXPORT int GetNextIndex(FrameBuffer* buf, int i, int* nexti);

/**
  @return An nvn error code indicating the success of the operation.
*/
EXPORT int GetPrevIndex(FrameBuffer* buf, int i, int* previ);

/**
  @return An nvn error code indicating the success of the operation.
*/
EXPORT int InitFrameBuffer(FrameBuffer* buf, int n);

/**
  @return An nvn error code indicating the success of the operation.
*/
EXPORT int IsEmpty(FrameBuffer* buf, int* empty);

/**
  @return An nvn error code indicating the success of the operation.
*/
EXPORT int IsValidIndex(FrameBuffer* buf, int i, int* valid);

/**
  @return An nvn error code indicating the success of the operation.
*/
EXPORT int RemoveFrame(FrameBuffer* buf, int frameIndex);

#endif